#ifndef _QI_INTERPRETER_H
#define _QI_INTERPRETER_H

#include <stdio.h>
#include "../q_common.h"



enum qi_opcode {
				OP_NOP = 0, OP_LOAD, OP_SAVE, OP_PUSHSTACK, OP_POPSTACK,
				OP_SET, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_EQUAL, OP_NOTEQUAL,
				OP_LOGAND, OP_LOGOR, OP_LOGXOR, OP_LOGNOT,
				OP_USERFUNC, OP_BIULDINFUNC, OP_RUNFUNC,  OP_DEFVAR, OP_DEFSTRUCT, OP_MAX
			};

struct qi_code
{
	int length;
	int offset;
	void* start;
	void* end;
};



struct qi_scriptholder
{
	FILE* handle;
	int chunksize;
	int pos;
	int maxpos;
	char* data;
};

int qi_fetchstring(char* buffer, int length);


int qi_openscriptfile(const char* const fname, int chunksize);
int qi_getscriptchar();

extern struct qi_scriptholder qi_script;


int initinterpreter();




#endif
